package model.eval;

import enums.FigureEnum;
import enums.TestPanelEnum;
import enums.TextBundleEnum;
import enums.URLEnum;
import misc.BundlesProvider;
import model.Sylogism;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Ejercicio de reduccion de modos;
 *
 * @author Jose Martin Rozanec;
 */
public class TestExerciseSylogismReduceMode extends TestExcercise {
    /**
     * Costructor;
     */
    public TestExerciseSylogismReduceMode() {
        this.panelEnum = TestPanelEnum.REDUCCION_MODOS;
    }

    public int getAchievedScore() {
        boolean correct = true;
        if (((Sylogism) getStudentsSolution()).getFigure() != FigureEnum.FIRST) {
            correct = false;
        }
        if (!((Sylogism) getExcerciseData()).getTerminoMayor().
                equalsIgnoreCase(((Sylogism) getStudentsSolution()).getTerminoMayor())) {
            correct = false;
        }
        if (!((Sylogism) getExcerciseData()).getTerminoMedio().
                equalsIgnoreCase(((Sylogism) getStudentsSolution()).getTerminoMedio())) {
            correct = false;
        }
        if (!((Sylogism) getExcerciseData()).getTerminoMenor().
                equalsIgnoreCase(((Sylogism) getStudentsSolution()).getTerminoMenor())) {
            correct = false;
        }
        if (correct) {
            return getCorrectScore();
        } else {
            return getIncorrectScore();
        }
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append(
                BundlesProvider.getBundle(URLEnum.TEXT_BUNDLE).getString(TextBundleEnum.REDUCCION_DE_MODOS.toString()));
        buffer.append(" [" + getCorrectScore() + "] [" + getIncorrectScore() + "] - \n"
                + ((Sylogism) getExcerciseData()).getReduceMode());
        buffer.append("\n" + ((Sylogism) getExcerciseData()).toString());
        return buffer.toString();
    }

    public String getStudentSolutionString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append(
                BundlesProvider.getBundle(URLEnum.TEXT_BUNDLE).getString(TextBundleEnum.REDUCCION_DE_MODOS.toString()));
        buffer.append(" [" + getCorrectScore() + "] [" + getIncorrectScore() + "] - \n"
                + ((Sylogism) getExcerciseData()).getReduceMode());
        buffer.append("\n" + ((Sylogism) getExcerciseData()).toString());
        return buffer.toString();
    }
}
